package com.kmv.master;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

/**
 *  
 */
public class MainFrame extends JFrame {

    public MainFrame( String title ) {
        super( title );
        this.setBounds( 100, 100, 300, 300 );
        this.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
        this.setVisible( true );
        this.init();
        this.initConnection();
    }

    public static void main( String[] args ) {
        MainFrame mainFrame = new MainFrame( "Task Scheduler" );
    }

    /**
     * 
     */
    private void init() {
        JButton runBtn = new JButton( "Run" );
        this.getContentPane().add( runBtn );
    }

    /**
     * 
     */
    private void initConnection() {
        System.setSecurityManager( new RMISecurityManager() );

        try {
            RunnerImpl taskRunner = new RunnerImpl();
            Naming.rebind( "//peppy:2005/PerfectTime", taskRunner );
        } catch ( RemoteException e ) {
            e.printStackTrace();
        } catch ( MalformedURLException e ) {
            e.printStackTrace();
        }

        System.out.println( "Ready to do time" );
    }

}
